package com.ita.listener;

import javax.jms.JMSException;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

import com.ita.activemq.Consumer;
import com.ita.factory.MQConnFactory;
import com.ita.redis.MerchantBlockFactory;

/**
 * Application Lifecycle Listener implementation class MQConnection
 * 
 */
@WebListener
public class MQConnListener implements ServletContextListener {

	/**
	 * Default constructor.
	 */
	public MQConnListener() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see ServletContextListener#contextInitialized(ServletContextEvent)
	 */
	public void contextInitialized(ServletContextEvent sce) {

//		MQConnFactory.open();
//
//		try {
//			new Consumer().start();
//		} catch (JMSException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		MerchantBlockFactory.initBlockMap();

	}

	/**
	 * @see ServletContextListener#contextDestroyed(ServletContextEvent)
	 */
	public void contextDestroyed(ServletContextEvent sce) {
		MQConnFactory.close();
	}

}
